home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / debugger / ddd-1.000 / ddd-1 / ddd-1.4b / vsllib / flow.vsl < prev    next >
Encoding:
Text File  |  1995-05-17  |  10.3 KB  |  395 lines

  1. // $Id: flow.vsl,v 1.2 1995/05/17 13:39:44 zeller Exp $ -- Makros zum Zeichnen von Flussdiagrammen
  2. //
  3.  
  4. // Copyright (C) 1993 Technische Universitaet Braunschweig, Germany.
  5. // Written by Andreas Zeller (zeller@ips.cs.tu-bs.de).
  6. // 
  7. // This file is part of the NORA Library.
  8. // 
  9. // The NORA Library is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU Library General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. // 
  14. // The NORA Library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. // See the GNU Library General Public License for more details.
  18. // 
  19. // You should have received a copy of the GNU Library General Public
  20. // License along with the NORA Library -- see the file COPYING.LIB.
  21. // If not, write to the Free Software Foundation, Inc.,
  22. // 675 Mass Ave, Cambridge, MA 02139, USA.
  23. // 
  24. // NORA is an experimental inference-based software development
  25. // environment. Contact nora@ips.cs.tu-bs.de for details.
  26.  
  27. #include "std.vsl"
  28. #include "slopes.vsl"
  29. #include "arcs.vsl"
  30.  
  31. // Flussdiagramme
  32.  
  33. // Version
  34. flow_version() = "$Revision: 1.2 $";
  35.  
  36. // Konstanten
  37.  
  38. // Mindestbreite/-laenge Verbindungslinie
  39. flow_space() = box(hspace(" "), whitethickness() * 5);    
  40.  
  41.  
  42. // Verbindungslinien
  43.  
  44. // Ecklinien
  45.  
  46. // Halbe Linien
  47. nn_flow() = hcenter(vrule() | vfill()) ^ flow_space();
  48. ss_flow() = hcenter(vfill() | vrule()) ^ flow_space();
  49. ee_flow() = vcenter(hfill() & hrule()) ^ flow_space();
  50. ww_flow() = vcenter(hrule() & hfill()) ^ flow_space();
  51.  
  52. nn_flow(c) = ((hspace(c) | vfill()) & (vrule() | vfill()) & fill()) ^ flow_space();
  53. ss_flow(c) = ((hspace(c) | vfill()) & (vfill() | vrule()) & fill()) ^ flow_space();
  54. ee_flow(c) = vcenter(hspace(c) & hrule()) ^ flow_space();
  55. ww_flow(c) = vcenter((hrule() | hspace(c)) & fill()) ^ flow_space();
  56.  
  57. // Ecken (xy_flow() = von x nach y)
  58. ne_flow(...) = nn_flow(...) ^ ee_flow(...);
  59. nw_flow(...) = nn_flow(...) ^ ww_flow(...);
  60. ns_flow(...) = nn_flow(...) ^ ss_flow(...);
  61.  
  62. wn_flow(...) = ww_flow(...) ^ nn_flow(...);
  63. we_flow(...) = ww_flow(...) ^ ee_flow(...);
  64. ws_flow(...) = ww_flow(...) ^ ss_flow(...);
  65.  
  66. se_flow(...) = ss_flow(...) ^ ee_flow(...);
  67. sw_flow(...) = ss_flow(...) ^ ww_flow(...);
  68. sn_flow(...) = ss_flow(...) ^ nn_flow(...);
  69.  
  70. es_flow(...) = ee_flow(...) ^ ss_flow(...);
  71. ew_flow(...) = ee_flow(...) ^ ww_flow(...);
  72. en_flow(...) = ee_flow(...) ^ nn_flow(...);
  73.  
  74.  
  75. // T-Linien
  76. n_tee(...) = nn_flow(...) ^ we_flow(...);
  77. w_tee(...) = ww_flow(...) ^ ns_flow(...);
  78. s_tee(...) = ss_flow(...) ^ we_flow(...);
  79. e_tee(...) = ee_flow(...) ^ ns_flow(...);
  80.  
  81.  
  82. // Verbindungspfeile
  83.  
  84. // Halbe, eingehende Pfeile
  85. nn_aflow() = hcenter(s_arrow() | vfill()) ^ flow_space();
  86. ss_aflow() = hcenter(vfill() | n_arrow()) ^ flow_space();
  87. ee_aflow() = vcenter(hfill() & w_arrow()) ^ flow_space();
  88. ww_aflow() = vcenter(e_arrow() & hfill()) ^ flow_space();
  89.  
  90. nn_aflow(c) = hspace(c) & (s_arrow() | vfill()) & hfill();
  91. ss_aflow(c) = hspace(c) & (vfill() | n_arrow()) & hfill();
  92. ee_aflow(c) = hspace(c) & vcenter(w_arrow());
  93. ww_aflow(c) = (hspace(c) | vcenter(e_arrow())) & hfill();
  94.  
  95. // T-Pfeile (Spitze trifft auf Balken)
  96. n_addflow(...) = nn_aflow(...) ^ we_flow(...);
  97. w_addflow(...) = ww_aflow(...) ^ ns_flow(...);
  98. s_addflow(...) = ss_aflow(...) ^ we_flow(...);
  99. e_addflow(...) = ee_aflow(...) ^ ns_flow(...);
  100.  
  101.  
  102.  
  103.  
  104. // Symbole
  105.  
  106. // Alle xxxFlow()-Funktionen geben ein Tupel (box, connect, labels, gotos) 
  107. // zurueck,
  108. // wobei box das erzeugte Bild und connect der horizontale Abstand
  109. // der Verbindungslinie ist.
  110.  
  111. // Hilfsfunktionen
  112.  
  113. fallbackFlow(box);
  114.  
  115. // max_connect bildet das Maximum ueber alle connect's
  116. max_connect((_, connect, _...)) = connect;
  117. max_connect((stmt1, connect1, _...), (stmt2, connect2, _...), ...) = 
  118.   if connect1 > connect2 then max_connect((stmt1, connect1), ...)
  119.                          else max_connect((stmt2, connect2), ...) fi;
  120.  
  121. // Hilfsfunktionen fuer noch nicht gebildete Flow's
  122. max_connect((stmt1, connect1, _...), box, ...) = 
  123.     max_connect((stmt1, connect1), fallbackFlow(box), ...);
  124. max_connect(box, ...) = max_connect(fallbackFlow(box), ...);
  125.  
  126.  
  127. // align richtet eine Box nach targetconnect aus
  128. align((box, boxconnect, _...), targetconnect) = 
  129.   (hspace(targetconnect - boxconnect)) & box;
  130. align(box, targetconnect) =
  131.   align(fallbackFlow(box), targetconnect);
  132.  
  133.  
  134. // attach fuegt einer Box oben und unten erweiterbare Verbindungen hinzu
  135.  
  136. attach((box, boxconnect, a...)) = 
  137. (
  138.   align((vrule(), 0), boxconnect)
  139. | box
  140. | align((vrule(), 0), boxconnect), boxconnect, a...);
  141.  
  142. attach(box, boxconnect) = attach((box, boxconnect, [], []));
  143.  
  144. attach(anybox) = attach(heven(anybox), hspace(heven(anybox)) / 2);
  145.  
  146.  
  147. // Einfache Symbole
  148.  
  149. // statFlow() erzeugt einfachen Rahmen (gewoehnliche Statements)
  150.  
  151. statFlow(stmt) = 
  152.   attach(fix(frame(stmt)));
  153.  
  154.  
  155. // fallbackFlow() wird benutzt, wenn Parameter kein Flow-Symbol ist
  156.  
  157. fallbackFlow(box) = statFlow("BAD BOX: " & frame(box));
  158.  
  159.  
  160. // callFlow() erzeugt Rahmen mit links und rechts doppelten Strichen
  161. // (Prozeduraufruf)
  162.  
  163. callFlow(stmt) = 
  164. attach(
  165.     hrule() 
  166.   | w_rule() & w_rule() & (hwhite() | stmt | hwhite()) & e_rule() & e_rule()
  167.   | hrule()
  168. );
  169.  
  170.  
  171. // printFlow() erzeugt Drucksymbol
  172.  
  173. printFlow(stmt) = 
  174. attach(
  175.     (sheet ^ square(vspace(stmt))) & 
  176.         (hrule() | whiteframe(stmt) | hrule()) & vrule()
  177.     where sheet = hrule() | (sw_arc90() & fill()) | fill() & ne_arc90()
  178. );
  179.  
  180.  
  181. // punchFlow() erzeugt Lochkartensymbol
  182.  
  183. punchFlow(stmt) = attach(punchcard(stmt));
  184.  
  185.  
  186. // ovalFlow() erzeugt Oval (fuer Start, Ende usw.)
  187.  
  188. ovalFlow(label) = attach(oval(label));
  189.  
  190.  
  191. // rhombFlow() erzeugt Raute fuer Tests
  192.  
  193. rhombFlow(cond, truelabel, falselabel) =
  194.   attach(rhomb(cond) ^ ne_flush(truelabel) ^ sw_flush(falselabel));
  195.  
  196.  
  197.  
  198. // Zusammengesetzte Symbole
  199.  
  200. // seqFlow() erzeugt vertikale Liste, mit vertikalen Linien verbunden
  201.  
  202. __seqFlow(max, (stmt, connect, _...)) = align((fix(stmt), connect), max);
  203. __seqFlow(max, (stmt, connect, _...), ...) =
  204.   __seqFlow(max, (stmt, connect))
  205. | align((vrule() & vspace(flow_space()), 0), max)
  206. | __seqFlow(max, ...);
  207. __seqFlow(max, box, ...) =
  208.   __seqFlow(max, fallbackFlow(box), ...);
  209.  
  210. _seqFlow(max, ...) = 
  211.   attach(__seqFlow(max, ...), max);
  212.  
  213. seqFlow(...) = 
  214.   _seqFlow(max_connect(...), ...);
  215.   
  216.  
  217.  
  218.  
  219.  
  220. // testFlow() wird fuer Tests verwendet
  221.  
  222. __testFlow(c1, c2, rhomb, truebody, falsebody) =
  223. attach(
  224.   ( vfix(align(rhomb, c1)) & vcenter(hrule())
  225.   | ns_flow(c1)
  226.   | align(falsebody, c1)
  227.   | ns_flow(c1)
  228.   | vfix(e_addflow(c1))
  229.   ) &
  230.   ( vspace(align(rhomb, c1) / 2)
  231.   | vfix(hrule() | hspace(c2))
  232.   | ns_flow(c2)
  233.   | align(truebody, c2)
  234.   | ns_flow(c2)
  235.   | vfix(hrule() | hspace(c2))
  236.   | vspace(e_addflow(c1) / 2 - 1)
  237.   )
  238. , c1);
  239.  
  240. _testFlow(rhomb, truebody, falsebody) =
  241.   __testFlow(
  242.     max_connect(rhomb, falsebody), max_connect(truebody),
  243.       rhomb, truebody, falsebody);
  244.  
  245. testFlow(cond, truebody, falsebody, tl, fl) =
  246.   _testFlow(rhombFlow(cond, tl, fl), truebody, falsebody);
  247.  
  248. testFlow(cond, truebody, falsebody) = 
  249.   testFlow(cond, truebody, falsebody, "T", "F");
  250.  
  251. testFlow(cond, (tb, tc, a...)) =
  252.   testFlow(cond, (tb, tc, a...), (ns_flow(tc), tc));
  253.  
  254. testFlow(cond, box) = 
  255.   testFlow(cond, fallbackFlow(box));
  256.  
  257.  
  258.  
  259.  
  260.  
  261. // positiveTopLoopFlow() erzeugt abweisende Schleife;
  262. // Schleife wird bei positivem Testergebnis durchlaufen.
  263.  
  264.  
  265. __positiveTopLoopFlow(c1, c2, rhomb, loopbody) =
  266. attach(
  267.   ( vfix(e_addflow(c1))
  268.   | vfix(align(rhomb, c1)) & vcenter(hrule())
  269.   | ns_flow(c1)
  270.   ) &
  271.   ( vfix(ew_flow(c2))
  272.   | vspace(align(rhomb, c1) / 2)
  273.   | fix(hrule() | hspace(c2))
  274.   | vfix(ns_flow(c2))
  275.   | align(loopbody, c2)
  276.   | vfix(ne_flow(c2))
  277.   ) &
  278.   ( fix(sw_flow())
  279.   | hfix(sn_flow())
  280.   | fix(wn_flow())
  281.   )
  282. , c1);
  283.  
  284. _positiveTopLoopFlow(rhomb, loopbody) =
  285.   __positiveTopLoopFlow(
  286.     max_connect(rhomb), max_connect(loopbody), rhomb, loopbody);
  287.  
  288. positiveTopLoopFlow(cond, loopbody, tl, fl) =
  289.   _positiveTopLoopFlow(rhombFlow(cond, tl, fl), loopbody);
  290.  
  291. positiveTopLoopFlow(cond, loopbody) =
  292.   positiveTopLoopFlow(cond, loopbody, "T", "F");
  293.  
  294.  
  295. // negativeTopLoopFlow() wie vor, 
  296. // aber Schleife wird bei negativem Testergebnis durchlaufen.
  297.  
  298.  
  299. __negativeTopLoopFlow(c, rhomb, loopbody) =
  300. attach(
  301.   ( fix(se_flow())
  302.   | hfix(sn_flow())
  303.   | fix(en_flow())
  304.   | vspace(es_flow(c))
  305.   ) &
  306.   ( vfix(w_addflow(c))
  307.   | align(rhomb, c) & vcenter(hrule())
  308.   | vfix(ns_flow(c))
  309.   | align(loopbody, c)
  310.   | vfix(nw_flow(c))
  311.   | vfix(es_flow(c))
  312.   ) &
  313.   ( vspace(w_addflow(c))
  314.   | vspace(align(rhomb, c) / 2)
  315.   | hfix((hrule() & hfill()) ^ hspace(flow_space()))
  316.   | hfix(ns_flow())
  317.   | fix(nw_flow())
  318.   )
  319. , hspace(se_flow() & c));
  320.  
  321. _negativeTopLoopFlow(rhomb, loopbody) =
  322.   __negativeTopLoopFlow(
  323.     max_connect(rhomb, loopbody), rhomb, loopbody);
  324.  
  325. negativeTopLoopFlow(cond, loopbody, tl, fl) =
  326.   _negativeTopLoopFlow(rhombFlow(cond, tl, fl), loopbody);
  327.  
  328. negativeTopLoopFlow(cond, loopbody) =
  329.   negativeTopLoopFlow(cond, loopbody, "T", "F");
  330.  
  331.  
  332.  
  333. // positiveBottomLoopFlow() erzeugt einweisende Schleife
  334. // Schleife wird bei positivem Testergebnis durchlaufen.
  335.  
  336. __positiveBottomLoopFlow(c, rhomb, loopbody) =
  337. attach(
  338.   ( vfix(e_addflow(c))
  339.   | align(loopbody, c)
  340.   | vfix(ns_flow(c))
  341.   | align(rhomb, c) & vcenter(hrule())
  342.   ) &
  343.   ( vfix(sw_flow())
  344.   | hfix(sn_flow())
  345.   | (hrule() & hfill()) ^ hspace(flow_space())
  346.   | vspace(align(rhomb, c) / 2)
  347.   )
  348. , c);
  349.  
  350. _positiveBottomLoopFlow(rhomb, loopbody) =
  351.   __positiveBottomLoopFlow(
  352.     max_connect(rhomb, loopbody), rhomb, loopbody);
  353.  
  354. positiveBottomLoopFlow(cond, loopbody, tl, fl) =
  355.   _positiveBottomLoopFlow(rhombFlow(cond, tl, fl), loopbody);
  356.  
  357. positiveBottomLoopFlow(cond, body) =
  358.   positiveBottomLoopFlow(cond, body, "T", "F");
  359.  
  360.  
  361. // negativeBottomLoopFlow() wie vor,
  362. // aber Schleife wird bei negativem Testergebnis durchlaufen.
  363.  
  364. __negativeBottomLoopFlow(c, rhomb, loopbody) =
  365. attach(
  366.   ( vfix(se_flow())
  367.   | sn_flow()
  368.   | vfix(en_flow())
  369.   | vspace(es_flow(c))
  370.   ) &
  371.   ( vfix(w_addflow(c))
  372.   | align(loopbody, c)
  373.   | vfix(ns_flow(c))
  374.   | ( align(rhomb, c)
  375.     | vfix(nw_flow(c))
  376.     | vfix(es_flow(c))
  377.     ) &
  378.     ( vspace(align(rhomb, c) / 2)
  379.     | fix((hrule() & hfill()) ^ hspace(flow_space()))
  380.     | hfix(ns_flow())
  381.     | fix(nw_flow())
  382.     )
  383.   )
  384. , hspace(se_flow() & c));
  385.  
  386. _negativeBottomLoopFlow(rhomb, loopbody) =
  387.   __negativeBottomLoopFlow(
  388.     max_connect(rhomb, loopbody), rhomb, loopbody);
  389.  
  390. negativeBottomLoopFlow(cond, loopbody, tl, fl) =
  391.   _negativeBottomLoopFlow(rhombFlow(cond, tl, fl), loopbody);
  392.  
  393. negativeBottomLoopFlow(cond, body) =
  394.   negativeBottomLoopFlow(cond, body, "T", "F");
  395.